package src.java.easy;

import java.util.Map;

public class Solution171 {
    public static void main(String[] args) {

        Solution171 solution = new Solution171();
        String columnTitle = "AB";
        int result = solution.titleToNumber(columnTitle);
        System.out.println(result);
    }

    public int titleToNumber(String columnTitle) {
        char[] charArray = columnTitle.toCharArray();
        int result = 0;
        int base = charArray.length;
        for (int i = 0; i < charArray.length; i++) {
            result += (charArray[i] - 'A' + 1) * Math.pow(26, base - 1);
            base--;
        }
        return result;
    }
}
